package com.quyunshuo.module.home.room.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.quyunshuo.module.home.room.entity.AppUsageEntity

@Dao
interface AppUsageDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(usage: AppUsageEntity)
    
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(usages: List<AppUsageEntity>)
    
    @Query("SELECT * FROM app_usage WHERE timestamp > :startTime ORDER BY timestamp DESC")
    suspend fun getUsageSince(startTime: Long): List<AppUsageEntity>
    
    @Query("DELETE FROM app_usage WHERE timestamp < :cutoffTime")
    suspend fun deleteOldRecords(cutoffTime: Long)
}